package com.yh.util;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;

public class PowerUtil {

    public static void intoSleep(Context ct, long delayInMillis){
        AlarmManager alarmManager = (AlarmManager) ct.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(ct, BroadcastReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(ct, 0, intent, 0);
        alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + delayInMillis, pendingIntent);
    }


    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            System.out.println("PowerUtil.onReceive = " + intent);
        }
    };


    public static void intoSleep2(Context ct){
//        JobScheduler jobScheduler = (JobScheduler) ct.getSystemService(Context.JOB_SCHEDULER_SERVICE);
//        JobInfo jobInfo = new JobInfo.Builder(jobId, new ComponentName(this, YourJobService.class))
//                .setRequiresDeviceIdle(true)
//                .setRequiresCharging(false)
//                .setPeriodic(intervalMillis)
//                .build();
//        jobScheduler.schedule(jobInfo);
    }


}
